package com.ruoyi.form.domain;

import com.alibaba.fastjson2.JSONObject;
import com.ruoyi.common.core.domain.entity.SysDictData;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

/**
 * 表单设计器使用
 */
@Data
public class Element {
    private String fieldId;
    private String modelId;
    private String parentId;
    private String basicCode;
    //  格式化后的code mongo存储
    private String codeShow;
    private String label;
    private Integer span;
    private JSONObject style;
    private String isDesign;
    private String tag;
    private String tagIcon;
    private String placeholder = "";
    private boolean disabled = true;
    private List<Option> options;
    private String icon = "";
    private String type = "";
    private String size = "";
    private List<SysDictData> dictList;
    private String basicJavaType;
    private String formTypeName;
    //add by lzf, 解决默认值
    private String defaultValue;
    //  新增文件限制类型
    private String exts;
    private String uploadTypeId;
    private boolean dataExtend;
    // 复杂属性 查看方式  0列表显示 1弹窗显示
    private String viewType;
    private String isReadOnly; //是否只读：0可编辑 1只读
    private Integer personNum;
    //是否必填
    private String jsRequired;
    //复杂属性
    private List<AxField> fuzaList;
    //组件类型(方便前使用)
    private String componentType;


    @Data
    static class Option {
        private String label;
        private Integer value;
    }

    public static List<Option> newOptionList(String flag) {
        String text = "选项";
        if ("1".equals(flag)) {
            text = "属性";
        }
        List<Option> list = new ArrayList<>();
        Option option = new Option();
        option.setLabel(text + "A");
        option.setValue(1);
        list.add(option);
        option = new Option();
        option.setLabel(text + "B");
        option.setValue(2);
        list.add(option);
        return list;
    }

}
